<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<body>  
    <!-- 1、使用data设置自定义属性 -->
    <div data-aid="1001" id="app">hello world</div>
    <script>
      // 2、获取自定义属性的值
        $("div").click(function(event){
            console.log(event.currentTarget.dataset.aid)
        })
        
        var app = document.getElementById("app");
        app.onclick = function(event){
            console.log(event.target.dataset.aid)
        }
    </script>
</body>
</html>